/*
 * @Author: 姚潘涛
 * @Date: 2024-10-12 20:48:42
 * @LastEditors: 姚潘涛
 * @LastEditTime: 2024-10-12 20:48:46
 * @Description:
 *
 * Copyright (c) 2024 by pandaman, All Rights Reserved.
 */
#pragma once

#include <cmath>
#include <utility>
#include <vector>

/// \brief Fast arctangent calculation using look-up table
/// \details This function provides a fast approximation of arctangent
/// using a look-up table. It sacrifices some accuracy for speed. \param
/// x The input value \return The approximate arctangent of x in radians
float atan_fast(float x);

/// \brief Single-precision arctangent calculation with linear
/// interpolation \details This function calculates arctangent using
/// linear interpolation between look-up table values for improved
/// accuracy. \param x The input value \return The arctangent of x in
/// radians
float atan_single(float x);

/// \brief Double-precision arctangent calculation
/// \details This function provides a more accurate arctangent
/// calculation using a higher precision look-up table and linear
/// interpolation. \param x The input value \return The arctangent of x
/// in radians
double atan_double(double x);

/// \brief Smoothstep function
/// \details This function provides a smooth interpolation between 0 and
/// 1 using a cubic Hermite spline. \param x The input value \return The
/// smoothstep value of x
float smoothstep(float x);

/// \brief Perform a simple linear fit (polynomial of degree 1)
/// \param x Vector of x coordinates
/// \param y Vector of y coordinates
/// \return Pair of floats representing the slope and intercept of the
/// fitted line
std::pair<float, float> polyfit(const std::vector<float>& x,
                                const std::vector<float>& y);

/// \brief Evaluate a linear polynomial at a given point
/// \param p Pair of floats representing the slope and intercept of the
/// line \param x The x-coordinate at which to evaluate the polynomial
/// \return The y-coordinate of the polynomial at x
float polyval(const std::pair<float, float>& p, float x);
